<!--
 * @Description: 第二十二章（transition-group过度列表） 基础
 * @Author: IA ia@kepro.space
 * @Date: 2025-02-17 18:44:03
-->
<template>
  <div>
    <h1>第二十二章（transition-group过度列表）基础</h1>
    <div class="container">
      <div>
        <h2>基础</h2>
        <div class="wrap">
          <transition-group>
            <div class="item" :key="item" v-for="item in list">{{ item }}</div>
          </transition-group>
        </div>
      </div>
      <div>
        <h2>tag</h2>
        <div class="wrap">
          <transition-group tag="section">
            <div class="item" :key="item" v-for="item in list">{{ item }}</div>
          </transition-group>
        </div>
      </div>
      <div>
        <h2>过度曲线</h2>
        <div>
          <el-button @click="add" type="primary">ADD</el-button>
          <el-button @click="pop" type="danger">POP</el-button>
          <div class="wrap">
            <transition-group
              enter-active-class="animate__animated animate__bounceIn"
              leave-active-class="animate__animated animate__hinge"
            >
              <div class="item" :key="item" v-for="item in list2">{{ item }}</div>
            </transition-group>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script setup lang="ts">
import { ref, reactive } from 'vue'
import 'animate.css'

const list = reactive<number[]>([1, 2, 3, 4, 5, 6])
const list2 = reactive<number[]>([1])

const add = () => {
  list2.push(list2.length + 1)
}

const pop = () => {
  list2.pop()
}
</script>
<style scoped lang="less">
h1,
h2 {
  margin: 20px 0;
}

.container {
  display: flex;
  flex-direction: column;
}

.wrap {
  display: flex;
  flex-wrap: wrap;
  word-wrap: break-all;
  border: 1px solid #ccc;

  .item {
    margin: 10px;
    font-size: 30px;
  }
}
</style>
